package com.gitee.wsl.mathematics.vector.ext


import com.gitee.wsl.mathematics.vector.vec2.Vector2
import com.gitee.wsl.mathematics.vector.vec3.Vector3
import com.gitee.wsl.mathematics.vector.vec4.Vector4

infix fun<T:Number,V:Vector2<T,V>,R:Vector2<T,R>> V.reflectFrom(normal: R):V{
    val norm = normal.normalized
    val factor = -2.0 * this dot norm
    return factor * norm + this
}
/*
infix fun<T:Number,V:Vector2<T,V>,R:Vector4<T,R>> V.reflectFrom(normal: R) = vec4 reflectFrom normal

infix fun<T:Number,V:Vector2<T,V>,R:Vector3<T,R>> V.reflectFrom(normal: R) = vec3 reflectFrom normal

infix fun<T:Number,V:Vector3<T,V>> V.reflectFrom(normal:Vector2<T,*>) = reflectFrom(normal.vec3)

infix fun<T:Number,V:Vector3<T,*>,Q:Vector3<T,*>> V.reflectFrom(normal: Q): Vector3<T,*> {
    val norm = normal.normalized as V
    val factor = -2.0 * (this dot norm)
    return factor * norm + this
}

infix fun<T:Number,V:Vector3<T,V>,Q:Vector3<T,*>> V.reflectFrom(normal: Q): V {
    val norm = normal.normalized
    val factor = -2.0 * (this dot norm)
    return factor * norm + this
}

infix fun<T:Number,V:Vector3<T,V>,R:Vector4<T,R>> V.reflectFrom(normal: R) = vec4 reflectFrom normal


infix fun<T:Number,V:Vector4<T,*>,R:Vector2<T,R>> V.reflectFrom(normal: R) = reflectFrom(normal.vec4)
infix fun<T:Number,V:Vector4<T,*>,R:Vector3<T,R>> V.reflectFrom(normal: R) = reflectFrom(normal.vec4)

infix fun<T:Number,V:Vector4<T,*>> V.reflectFrom(normal: V): Vector4<T,*> {
    val norm = normal.normalized as V
    val factor = -2.0 * (this dot norm)
    return factor * norm + this
}

infix fun<T:Number,V:Vector4<T,V>,R:Vector4<T,R>> V.reflectFrom(normal: R): R {
    val norm = normal.normalized
    val factor = -2.0 * this dot norm
    return factor * norm + this
}*/

